//
//  FunctionButton.m
//  CareRing
//
//  Created  on 2024/12/13.
//
    

#import "FunctionButton.h"
#import "Colors.h"

@interface FunctionButton()

@property(copy, nonatomic)void(^tapBlk)(FunctionButton *btn);

@end

@implementation FunctionButton

+(FunctionButton *)functionButton:(NSString *)title
{
    
    FunctionButton *btn = [FunctionButton buttonWithType:UIButtonTypeCustom];
    [btn setTitleColor:MAIN_BLUE forState:UIControlStateNormal];

    [btn setTitle:title forState:UIControlStateNormal];
    
    btn.layer.borderWidth = 0.5;
    btn.layer.borderColor = MAIN_BLUE.CGColor;
    btn.layer.cornerRadius = 3.f;
    btn.clipsToBounds = YES;
    
    return btn;
}



-(void)addTapBlk:(void(^)(FunctionButton *btn))tapBlk
{
    [self addTarget:self action:@selector(tap:) forControlEvents:UIControlEventTouchUpInside];

    self.tapBlk = tapBlk;
    
}

-(void)tap:(FunctionButton *)btn {
    if (self.tapBlk) {
        self.tapBlk(self);
    }
    
}

@end
